﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Xml.Serialization;

namespace Futajma.MigrationStudio.DataDefinition
{
    [ObfuscationAttribute(Exclude = true, ApplyToMembers = true)]
    public enum SharePointType
    {
        NotDefined = -1,
        Application = 0,
        SiteCollection = 1,
        Site = 2,
        //   Library = 3,
        DocLibrary = 4,
        Folder = 5,
        Item = 6,
        Document = 7
    }

    [Flags]
    [ObfuscationAttribute(Exclude = true, ApplyToMembers = true)]
    public enum ViolationType
    {
        NoViolation = 0,
        ItemThresholdExceeded = 1,
        ItemSizeExceeded = 2,
        PathLengthExceeded = 4,
        FileNameDuplicated = 8,
        FilePathNameLengthExceeds = 16,
        IllegalFileExtensionDetected = 32,
        IllegalFileAndFolderCharacterDetected = 64,
        IllegalSiteAndSubsiteCharacterDetected = 128,
        ItemThresholdExceededWarning = 256,
    }


    //public enum LiveLinkType
    //{
    //    NotDefined = -1,
    //    Folder = 0,
    //    Alias = 1,
    //    CompoundDocument = 136,
    //    Item = 140,
    //    Document = 144,
    //    TextFile = 145,
    //    ProjectSite = 202,
    //    NotALiveLinkSource = -2
    //}

    [XmlRoot(Namespace = "DataDefinition")]
    [ObfuscationAttribute(Exclude = true, ApplyToMembers = true)]
    public class DataNode
    {
        public DataNode()
        {
            //Id = Guid.NewGuid();
        }

        public string Title { get; set; }
        [XmlIgnore]
        public string EncodedTitle { get { return Title.Replace(" ", "%20"); } }
        public string SourcePath { get; set; }
        public string SourceUrl { get; set; }
        public string TargetPath { get; set; }
        public SharePointType SharePointType { get; set; }

        public int FileSize { get; set; }

        public int ItemCount { get; set; }
        [XmlIgnore]
        public long NodeSize { get; set; }
        [XmlIgnore]
        public int NodeCount { get; set; }
        [XmlIgnore]
        public int PathLength { get; set; }


        #region Governance
        [XmlIgnore]
        public ViolationType ViolationType { get; set; }
        [XmlIgnore]
        public int ItemThresholdExceededCount { get; set; }
        [XmlIgnore]
        public int ItemSizeExceededCount { get; set; }

        [XmlIgnore]
        public bool GovernanceViolation { get; set; }
        [XmlIgnore]
        public int GovernanceViolationCollected { get; set; }

        [XmlIgnore]
        public bool SharePointStructureViolation { get; set; }
        [XmlIgnore]
        public int SharePointStructureViolationCollected { get; set; }

        [XmlIgnore]
        public long DuplicatedFilenameViolationCount { get; set; }

        #endregion

        public string SourceId { get; set; }

        public bool CommitedItem { get; set; }
        //public bool UpdatedItem { get; set; }

        public int Version { get; set; }
        public int PreviousVersion { get; set; }

        //public bool Deletable { get; set; }

        //public bool ExcludeFromMigration { get; set; }

        public bool RemoveFolderStructure { get; set; }

        //public bool ExcludeableFromMigration { get; set; }

        public Guid TemplateId { get; set; }

        public bool NodeDisabled { get; set; }

        //public Guid Id { get; set; }

    }
}
